package com.example.wangzh.mytest.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.Nullable;

import com.example.wangzh.mytest.constant.LogTag;

public class TransformationTouchTestView extends View {
    public TransformationTouchTestView(Context context) {
        super(context);
    }

    public TransformationTouchTestView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public TransformationTouchTestView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public TransformationTouchTestView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
            Log.d(LogTag.WZH_TEST, String.format("event.getX():%f event.getY():%f width:%d", event.getX(),
                    event.getY(), getWidth()));
        } else if (event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
            Log.d(LogTag.WZH_TEST, String.format("ACTION_POINTER_DOWN event.getX():%f event.getY():%f width:%d",
                    event.getX(),
                    event.getY(), getWidth()));
        } else if (event.getActionMasked() == MotionEvent.ACTION_MOVE && event.getPointerCount() == 2) {
            Log.d(LogTag.WZH_TEST, String.format("ACTION_MOVE event.getX(0):%f event.getY(0):%f event.getX(0):%f event.getY(0):%f width:%d", event.getX(0), event.getY(0), event.getX(1), event.getY(1), getWidth()));
        }
        return true;
    }
}
